const storeContainer: {
    [key: string]: PlayerStore<any>
} = {}
/**
 * 玩家存储
 */
export class PlayerStore<T> {
    store?: Map<number, T>
    getStore() {

    }

    /**
     * 
     * @param nameSpace 存储空间 如果没有，就是缓存
     */
    constructor(
        public nameSpace: string | undefined) {
    }
    setByPlayer(player: Player, entity: T) {

    }
    getByPlayer(player: Player) {
        const result = this.store?.get(player.UserId)
        return result;
    }
    /** 在容器中注册存储 */
    register() {
        if (!this.nameSpace || game.GetService('RunService').IsClient()) {
            this.store = new Map();
            return
        }
        if (storeContainer[this.nameSpace] !== undefined) {
            throw (this.nameSpace + " is Duplicate!")
        }
        (storeContainer[this.nameSpace] as any) = this
    }
}